package top.gytf.unifiedcall.model.code.builtin;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import top.gytf.unifiedcall.jsr269.code.CodeLocationConstants;
import top.gytf.unifiedcall.jsr269.exception.GenException;
import top.gytf.unifiedcall.model.code.NamespaceCode;
import top.gytf.unifiedcall.model.code.StatusCode;
import top.gytf.unifiedcall.model.code.SymbolCode;

/**
 * 内置状态码
 */
@CodeLocationConstants
@GenException(basePackage = "top.gytf.unifiedcall.model.exception.builtin")
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum BuiltinStatusCode implements StatusCode {
    @GenException.Ignore
    SUCCESS(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.SUCCESS, "000000", "成功"),

    UNKNOWN_FAIL(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL, "100000", "未知错误"),

    SERVICE_UNAVAILABLE(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100001", "服务不可用"),

    INVALID_STATE(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLER, "100002", "状态异常"),
    INVALID_PARAMETER(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLER, "100003", "参数无效"),
    ACCESS_DENIED(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLER, "100004", "访问被拒绝"),

    NOT_FOUND(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLER, "100005", "未找到资源"),
    DUPLICATE(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLER, "100006", "资源已存在"),

    OPERATION_UNSUPPORTED(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100007", "操作未支持"),
    INSERT_FAIL(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100008", "插入失败"),
    UPDATE_FAIL(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100009", "更新失败"),
    DELETE_FAIL(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100010", "删除失败"),
    QUERY_FAIL(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100011", "查询失败"),
    EXECUTE_FAIL(BuiltinNamespaceCode.DEFAULT, BuiltinSymbolCode.FAIL_CALLEE, "100012", "执行失败"),
    ;

    private final NamespaceCode namespace;
    private final SymbolCode symbol;
    private final String serial;
    private final String message;

    @Override
    public NamespaceCode namespace() {
        return namespace;
    }

    @Override
    public SymbolCode symbol() {
        return symbol;
    }

    @Override
    public String serial() {
        return serial;
    }

    @Override
    public String message() {
        return message;
    }
}
